package com.zlq.cn.controller.sign.exam;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zlq.cn.annotations.UnPrintResult;
import com.zlq.cn.api.SignApiResult;
import com.zlq.cn.controller.BaseController;
import com.zlq.cn.entity.ExamAnswers;
import com.zlq.cn.entity.ExamQuestions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import com.zlq.cn.service.exam.ExamAnswersService;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Objects;

/**
 * 考试题库-题目选项
 *
 * @author zhoucl
 * @since 2024-04-10
 */
@Api(tags = "考试题库-题目选项")
@RestController
@RequestMapping("/exam/answers")
public class ExamAnswersController extends BaseController {

    @Resource
    private ExamAnswersService examAnswersService;

    @UnPrintResult
    @ApiOperation("题目选项列表")
    @PostMapping("/list")
    public SignApiResult<List<ExamAnswers>> list(@RequestBody ExamAnswers examAnswers) {
        return SignApiResult.resultSuccess(examAnswersService.lambdaQuery()
                .eq(Objects.nonNull(examAnswers.getQuestionId()), ExamAnswers::getQuestionId, examAnswers.getQuestionId())
                .list());
    }

    @UnPrintResult
    @ApiOperation("题目选项列表-分页")
    @PostMapping("/page")
    public SignApiResult<Page<ExamAnswers>> page(@RequestBody ExamAnswers examAnswers) {
        return SignApiResult.resultSuccess(examAnswersService.lambdaQuery()
                .eq(Objects.nonNull(examAnswers.getQuestionId()), ExamAnswers::getQuestionId, examAnswers.getQuestionId())
                .page(super.<ExamAnswers>getPage()));
    }
}

